<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class model_chart extends CI_Model{

    public function __construct()
    {
        parent::__construct();
    }
    
    function get_kasus_by_hub(){
        $q = $this->db->query("SELECT COUNT(*) AS count, IF(pelaku_hub IS NULL,'N/A',IF(pelaku_hub = '','N/A',pelaku_hub)) AS pelaku_hub FROM `tbl_kasus` GROUP BY `pelaku_hub`");
        return $q->result();
    }
    function get_kasus_by_hiv(){//berdasarkan status HIV
        $q = $this->db->query("SELECT COUNT(*) AS count, IF(korban_statushiv IS NULL,'N/A',IF(korban_statushiv = '','N/A',korban_statushiv)) AS korban_statushiv FROM `tbl_kasus` GROUP BY `korban_statushiv`");
        return $q->result();
    }
    function get_kasus_by_informer(){//berdasarkan kategori pelapor
        $q = $this->db->query("SELECT COUNT(*) AS count, IF(alias IS NULL,'N/A',IF(alias = '','N/A',alias)) AS alias FROM `tbl_kasus` GROUP BY `alias`");
        return $q->result();
    }
    function get_kasus_by_assistance(){//berdasarkan kategori pelapor
        $q = $this->db->query("SELECT COUNT(*) AS count, IF(tl_value IS NULL,'N/A',IF(tl_value = '','N/A',tl_value)) AS tl_value FROM `tbl_kasus` GROUP BY `tl_value`");
        return $q->result();
    }
    function get_kasus_by_persecution(){//berdasarkan kategori pelapor
        $q = $this->db->query("SELECT COUNT(*) AS count, IF(jenis_kasus IS NULL,'N/A',IF(jenis_kasus = '','N/A',jenis_kasus)) AS jenis_kasus FROM `tbl_kasus` as A RIGHT OUTER JOIN `tbl_jenis_kasus` as B ON A.id_kasus = B.id_kasus  GROUP BY `jenis_kasus`");
        return $q->result();
    }
    function get_kasus_by_query($query){//berdasarkan kueri pada filter
        $q = $this->db->query($query);
        return $q->result();
    }
}
/* End of file model_chart.php */
/* Location: ./application/models/model_chart.php */
